home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 May: Tool Chest / Developer CD Series May 1996 (Tool Chest) (Apple Computer) (1996).iso / Tool Chest / Text / WASTE / WASTE 1.1.2 Distribution / Demo Source / WEDemoPictures.p < prev    next >
Encoding:
Text File  |  1995-10-12  |  1.8 KB  |  74 lines  |  [TEXT/CWIE]

  1. unit WEDemoPictures;
  2.  
  3. { WASTE DEMO PROJECT: }
  4. { Object Handlers for embedded pictures }
  5.  
  6. { Copyright © 1993-1995 Marco Piovanelli }
  7. { All Rights Reserved }
  8.  
  9. interface
  10.     uses
  11.         WEDemoIntf;
  12.  
  13.     function HandleNewPicture (var defaultObjectSize: Point;
  14.                                     objectRef: WEObjectReference): OSErr;
  15.     function HandleDisposePicture (objectRef: WEObjectReference): OSErr;
  16.     function HandleDrawPicture ({const} var destRect: Rect;
  17.                                     objectRef: WEObjectReference): OSErr;
  18.  
  19. implementation
  20.  
  21.     function HandleNewPicture (var defaultObjectSize: Point;
  22.                                     objectRef: WEObjectReference): OSErr;
  23.         var
  24.             thePicture: PicHandle;
  25.             frame: Rect;
  26.     begin
  27.  
  28. { get handle to object data (in this case, a picture handle) }
  29.         thePicture := PicHandle(WEGetObjectDataHandle(objectRef));
  30.  
  31. { figure out the default object size by looking at the picFrame record }
  32.         frame := thePicture^^.picFrame;
  33.         OffsetRect(frame, -frame.left, -frame.top);
  34.         defaultObjectSize := frame.botRight;
  35.  
  36. { return error code }
  37.         HandleNewPicture := noErr;
  38.  
  39.     end;  { HandleNewPicture }
  40.  
  41.     function HandleDisposePicture (objectRef: WEObjectReference): OSErr;
  42.         var
  43.             thePicture: PicHandle;
  44.     begin
  45.  
  46. { get handle to object data (in this case, a picture handle) }
  47.         thePicture := PicHandle(WEGetObjectDataHandle(objectRef));
  48.  
  49. { kill the picture }
  50.         KillPicture(thePicture);
  51.  
  52. { return error code }
  53.         HandleDisposePicture := MemError;
  54.  
  55.     end;  { HandleDisposePicture }
  56.  
  57.     function HandleDrawPicture ({const} var destRect: Rect;
  58.                                     objectRef: WEObjectReference): OSErr;
  59.         var
  60.             thePicture: PicHandle;
  61.     begin
  62.  
  63. { get handle to object data (in this case, a picture handle) }
  64.         thePicture := PicHandle(WEGetObjectDataHandle(objectRef));
  65.  
  66. { draw the picture }
  67.         DrawPicture(thePicture, destRect);
  68.  
  69. { return error code }
  70.         HandleDrawPicture := noErr;
  71.  
  72.     end;  { HandleDrawPicture }
  73.  
  74. end.